<?php

class m_infus extends CI_Model {

	function infus($data = '') {

		$data = $this -> db -> get('infus');
		return $data -> result_array();
	}
        
        function pasien($data = '') {

		$data = $this -> db -> get('pasien');
		return $data -> result_array();
	}

	function cekbyidinfus($id_infus = '') {
		$this -> db -> where('id_infus', $id_infus);
		$data = $this -> db -> get('cek');
		return $data -> result_array();
	}

	function login($username = '', $password = '') {

		$this -> db -> where('username', $username);
		$this -> db -> where('password', $password);
		$data = $this -> db -> get('user') -> result_array();

		if (sizeof($data) != 0)
			return $data[0]['id'];
		else
			return '0';
	}

	function pasienbyid($id = '') {
		$this -> db -> where('id', $id);
		$data = $this -> db -> get('pasien') -> result_array();
		return $data;
	}

	function tambahInfus($data = '') {
		$this -> db -> trans_start();
		$this -> db -> insert('infus', $data);
		$this -> db -> trans_complete();
		return $this -> db -> trans_status();
	}

	function tambahCek($data = '') {
		$this -> db -> trans_start();
		$this -> db -> insert('cek', $data);
		$this -> db -> trans_complete();
		return $this -> db -> trans_status();
	}

	function ubahInfus($data = '', $id_infus = '') {
		$this -> db -> trans_start();
		$this -> db -> where('id', $id_infus);
		$this -> db -> update('infus', $data);
		$this -> db -> trans_complete();
		return $this -> db -> trans_status();
	}

	function ubahCek($request = '', $id_cek = '') {
		$this -> db -> trans_start();
		$this -> db -> where('id', $id_cek);
		$this -> db -> update('cek', $data);
		$this -> db -> trans_complete();
		return $this -> db -> trans_status();
	}

	function deleteInfus($id_infus = '') {
		$this -> db -> trans_start();
		$this -> db -> where('id', $id_infus);
		$this -> db -> delete('infus');
		$this -> db -> trans_complete();
		return $this -> db -> trans_status();
	}

	function deleteCek($id_cek = '') {
		$this -> db -> trans_start();
		$this -> db -> where('id', $id_cek);
		$this -> db -> delete('cek');
		$this -> db -> trans_complete();
		return $this -> db -> trans_status();
	}
        
        function ubahAlarm($data="",$id_infus=0){
            $this -> db -> trans_start();
            $this -> db -> where('id', $id_infus);
            $this -> db -> update('infus', $data);
            $this -> db -> trans_complete();
            return $this -> db -> trans_status();
        }

}
?>